package si.yun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import si.yun.dao.OpeHomesDao;
import si.yun.entity.OpCourseList;
import si.yun.service.OpesService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName OpeHomeServiceImpl
 * @description:
 * @Author DZQ
 * @Date 2021/7/29 16:19
 **/
@Service
public class OpeHomesServiceImpl implements OpesService {
@Autowired
private OpeHomesDao dao;
    /**
     * @author: DZQ
     * @description: 课程列表zTree
     * @date: 2021/8/27 15:46
     * @return
     */
    /*
    @Override
    public List<Map<String, Object>> getztree(Integer parentId) {
        List<Map<String,Object>> list=new ArrayList<>() ;
        List<Map<String,Object>> maps = dao.getZtree(0) ;
        for (Map<String,Object> map :maps) {
            int id = (int) map.get("id");
            map.put(" open", true);
            List<Map<String, Object>> child = getChildren(id);
            map.put(" children", child);
            list.add(map);
        }
        return list;
    }

    //封装获取子节点的方法
    public List<Map<String,Object>> getChildren(Integer id) {
        //根据父节点获取子节点
        List<Map<String,Object>> children = dao.getZtree(id);
        //三级目录
        if(children!=null) {
            for(Map<String,Object> child:children) {
                int id2 = (int) child.get("id");
                List<Map<String,Object>> children2=getChildren(id2);
                child.put("children",children2);
            }
        }
        return children;
    }
*/
    /**
     * @author: DZQ
     * @description: 获取全部订单，待付款，已完成，已取消的表格信息
     * @date: 2021/8/27 16:17
     * @return
     */
    @Override
    public List<Map<String, Object>> COStatus(Integer orderStatus, Integer orderType) {
        List<Map<String,Object>> list=dao.COStatus(orderStatus,orderType);
        return list;
    }
    /**
     * @author: DZQ
     * @description: 获取课程订单列表状态信息
     * @date: 2021/8/25 14:45
     * @return
     */
    @Override
    public List<Map<String, Object>> status(Integer orderType) {
        List<Map<String,Object>> list=dao.status(orderType);
        return list;
    }
    /**
     * @author: DZQ
     * @description: 查询按钮
     * @date: 2021/8/27 19:39
     * @return
     */
    @Override
    public List<Map<String, Object>> query(Integer orderNo, Integer account, Integer orderPaymentChannel,Integer orderStatus,Integer orderType) {
        List<Map<String,Object>> list=dao.query(orderNo,account,orderPaymentChannel,orderStatus,orderType);
        return list;
    }
    /**
     * @author: DZQ
     * @description: 课程订单总数
     * @date: 2021/9/4 14:44
     * @return
     */
    @Override
    public Map<String, Object> getNumber(int result1, int result2, int result3, int result4) {
        int list=dao.getNumber(result1);
        int list1=dao.getNumber1(result2);
        int list2=dao.getNumber2(result3);
        int list3=dao.getNumber3(result4);
        Map<String,Object> m = new HashMap<>();
        m.put("allNumber",list);
        m.put("payNumber",list1);
        m.put("completeNumber",list2);
        m.put("cancelNumber",list3);
        return m;
    }

    @Override
    public Map<String, Object> selOul(Integer id) {
        return dao.selOul(id);
    }

    @Override
    public List<Map<String, Object>> Retrieve(Integer orderSource, String createDate, Integer orderNo, Integer account, Integer orderPaymentChannel, Integer orderStatus, Integer orderType) {
        List<Map<String,Object>> list=dao.Retrieve(orderSource,createDate,orderNo,account,orderPaymentChannel,orderStatus,orderType);
        return list;
    }
}
